/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package kodi.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.*;
import java.util.HashSet;
import java.util.List;
import kodi.model.UserRights.Task;

@Entity
public class User implements Serializable {
    private int user_id;
    private String name;
    private String password;
    private int phoneNo;
    private String job_title;
    private String email;
    private Date employed_date;
    private Status status;
    private Set<Task> tasklist = new HashSet<Task>(0);
   // private List tasklist;
    //private RoleTask roletask;
    public User(){    }

    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
    public int getUser_id() {
        return user_id;
    }
    @Column(name = "Name", nullable = false, length = 100)
    public String getName() {
        return name;
    }
    @Column(name = "Password", nullable = false, length = 8)
    public String getPassword() {
        return password;
    }
    @Column(name = "PhoneNo", nullable = false, length = 8)
    public int getPhoneNo() {
        return phoneNo;
    }
    @Column(name = "Jon_Title", nullable = false, length = 100)
    public String getJob_title() {
        return job_title;
    }
    @Column(name = "Email", nullable = false, length = 100)
    public String getEmail() {
        return email;
    }

    @Temporal(javax.persistence.TemporalType.DATE)
    @Column(name = "Employed_Date", nullable = false)
    public Date getEmployed_date() {
        return employed_date;
    }

    @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name="status_id", table="status" )
    public Status getStatus() {
        return status;
    }

    public void setUser_id(int user_id) {
        this.user_id = user_id;
    }
    public void setStatus(Status status) {
        this.status = status;
    }

    public void setEmployed_date(Date employed_date) {
        this.employed_date = employed_date;
    }

    public void setJob_title(String job_title) {
        this.job_title = job_title;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setPhoneNo(int phoneNo) {
        this.phoneNo = phoneNo;
    }


    public void setName(String name) {
        this.name = name;
    }
     public boolean equals(Object other) {
        if (this == other) return true;
        if ( !(other instanceof User) ) return false;

        final User user = (User) other;
        if ( user.getUser_id()!= getUser_id() ) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = 29 * getUser_id();
        return result;
    }

    public Set<Task> getTasklist() {
        return tasklist;
    }

    public void setTasklist(Set<Task> tasklist) {
        this.tasklist = tasklist;
    }
}
